package com.yanqu.road.dataHelper.del.mgr;

import com.yanqu.road.dataHelper.manager.BaseMgr;
import com.yanqu.road.utils.MyProperties;
import com.yanqu.road.utils.string.StringUtils;

import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class GameDelMgr extends BaseMgr {

    private static Map<String, List<String>> tableMap = new ConcurrentHashMap<>();

    private static Map<String, List<String>> tableLogMap = new ConcurrentHashMap<>();

    private static MyProperties props;

    public static boolean init(String dirPath) {
        String path = dirPath + "config" + File.separator;
        String name = "del.properties";
        props = new MyProperties(path + name);
        String dbGameStr = props.getProperty("db_game");
        if(!StringUtils.isNullOrEmpty(dbGameStr)){
            List<String> infoStrList = StringUtils.stringToStringList(dbGameStr,"\\|");
            for(String infoStr : infoStrList){
                List<String> infoList = StringUtils.stringToStringList(infoStr,";");
                tableMap.put(infoList.get(0),infoList);
            }
        }
        String dbGameLogStr = props.getProperty("db_game_log");
        if(!StringUtils.isNullOrEmpty(dbGameLogStr)){
            List<String> infoLogStrList = StringUtils.stringToStringList(dbGameLogStr,"\\|");
            for(String infoLogStr : infoLogStrList){
                List<String> infoList = StringUtils.stringToStringList(infoLogStr,";");
                tableLogMap.put(infoList.get(0),infoList);
            }
        }

        return true;
    }

    public static Map<String, List<String>> getTableMap() {
        return tableMap;
    }

    public static Map<String, List<String>> getTableLogMap() {
        return tableLogMap;
    }
}
